"""
修改客户关怀页面
"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from selenium.webdriver.support.select import Select

class EditorialCustomerCarePage(BasePage):
    #定位器
    #客户
    kh_khgh_xgkhgh_kh_locator = (By.ID, "customer_name")
    #联系人
    kh_khgh_xgkhgh_lxr_locator = (By.ID, "contacts_name")
    #关怀主题
    kh_khgh_xgkhgh_ghzt_locator = (By.ID, "name")
    #关怀日期
    kh_khgh_xgkhgh_ghrq_locator = (By.ID, "contacts_name")
    #执行人
    kh_khgh_xgkhgh_zxr_locator = (By.ID, "owner_name")
    #关怀类型
    kh_khgh_xgkhgh_ghlx_locator = (By.ID, "type")
    #关怀内容
    kh_khgh_xgkhgh_ghlr_locator = (By.CSS_SELECTOR,
                                   "body > div.container > div.row > div > form > table > tbody > tr:nth-child(5) > td:nth-child(2) > textarea")
    #备注
    kh_khgh_xgkhgh_bz_locator = (By.CSS_SELECTOR,
                                 "body > div.container > div.row > div > form > table > tbody > tr:nth-child(6) > td:nth-child(2) > textarea")
    #保存
    kh_khgh_xgkhgh_bc_locator = (By.CSS_SELECTOR,
                                 "body > div.container > div.row > div > form > table > thead > tr > td:nth-child(2) > input.btn.btn-primary")


    #输入客户
    def input_kh(self,kh):
        self.driver.find_element(*self.kh_khgh_xgkhgh_kh_locator).clear()
        self.driver.find_element(*self.kh_khgh_xgkhgh_kh_locator).send_keys(kh)

    #输入联系人
    def input_lxr(self,lxr):
        self.driver.find_element(*self.kh_khgh_xgkhgh_lxr_locator).clear()
        self.driver.find_element(*self.kh_khgh_xgkhgh_lxr_locator).send_keys(lxr)

    #输入关怀主题
    def input_ghzt(self,ghzt):
        self.driver.find_element(*self.kh_khgh_xgkhgh_ghzt_locator).clear()
        self.driver.find_element(*self.kh_khgh_xgkhgh_ghzt_locator).send_keys(ghzt)

    #输入关怀日期
    def input_ghrq(self,ghrq):
        self.driver.find_element(*self.kh_khgh_xgkhgh_ghrq_locator).clear()
        self.driver.find_element(*self.kh_khgh_xgkhgh_ghrq_locator).send_keys(ghrq)

    #输入执行人
    def input_zxr(self,zxr):
        self.driver.find_element(*self.kh_khgh_xgkhgh_zxr_locator).clear()
        self.driver.find_element(*self.kh_khgh_xgkhgh_zxr_locator).send_keys(zxr)

    #选择关怀类型
    def choose_ghlx(self, index):
        source = self.driver.find_element(*self.kh_khgh_xgkhgh_ghlx_locator)
        Select(source).select_by_index(index)

    #输入关怀内容
    def input_ghlr(self,ghnr):
        self.driver.find_element(*self.kh_khgh_xgkhgh_ghlr_locator).clear()
        self.driver.find_element(*self.kh_khgh_xgkhgh_ghlr_locator).send_keys(ghnr)

    #输入备注
    def input_bz(self,bz):
        self.driver.find_element(*self.kh_khgh_xgkhgh_bz_locator).clear()
        self.driver.find_element(*self.kh_khgh_xgkhgh_bz_locator).send_keys(bz)

    #点击保存
    def click_bc(self):
        self.driver.find_element(*self.kh_khgh_xgkhgh_bc_locator).click()